package mylib.archive.y2012.m09.IFMO_Train;

import mylib.dir.FastInputReader;
import mylib.dir.MatrixUtils;

import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;

public class TaskJ {
    public void solve(int testNumber, FastInputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int[][] d = new int[n][n];
        MatrixUtils.fill(d, -1);
        for (int i = 0; i < m; ++i) {
            int x = in.nextInt();
            int y = in.nextInt();
            --x;
            --y;
            d[x][y] = d[y][x] = 1;
        }
        boolean[][][] can = new boolean[n][n][n];
        for (int from = 0; from < n; ++from) {
            for (int exlusive = 0; exlusive < n; ++exlusive) {
                if (from == exlusive) continue;
                can[from][exlusive][from] = true;
                Queue<Integer> queue = new LinkedList<Integer>();
                queue.add(from);
                while (!queue.isEmpty()) {
                    int p = queue.poll();
                    for (int to = 0; to < n; ++to) {
                        if (d[p][to] == -1)
                            continue;
                        if (to == exlusive)
                            continue;
                        if (can[from][exlusive][to])
                            continue;
                        can[from][exlusive][to] = true;
                        queue.add(to);
                    }
                }
            }
        }
        boolean ok = true;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (d[i][j] == -1)
                    continue;
                for (int k = 0; k < n; ++k) {
                    if (d[j][k] == -1)
                        continue;
                    for (int mid = 0; mid < n; ++mid) {
                        if (i == j || i == k || i == mid || j == k || j == mid || k == mid)
                            continue;
                        if (can[k][j][mid] && can[i][j][mid] && can[i][k][mid] && can[k][i][mid])
                            ok = false;
                    }
                }
            }
        }
        out.print(ok ? "YES" : "NO");

    }
}
